{% extends 'template.html' %}

{% block username %}
    {{ head.username }}
{% endblock %}

{% block content %}
    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <h1 class="page-header">{{ head.value }}</h1>
                <h1 class="page-header" id="wse_id" style="display: none;">{{ data.id }}</h1>
            </div>
        </div>
        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <div class="panel-body">
                        <div class="row">
                            <div class="col-lg-6">
                                <div class="container">
                                    <form role="form" class="form-horizontal">
                                        <div class="form-group">
                                            <label class="col-sm-12">申请人</label>
                                            <div class="col-sm-6">
                                                <input class="form-control" id="applicant"
                                                       value={{ data.applicant }} readonly="readonly"></input>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-12" for="TextArea">标题</label>
                                            <div class="col-sm-6">
                                                <input class="form-control" id="title"
                                                       value={{ data.title }} readonly="readonly"></input>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-12" for="TextArea">项目</label>
                                            <div class="col-sm-6">
                                                <input class="form-control" id="project"
                                                       value={{ data.project }} readonly="readonly"></input>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-12" for="TextArea">用途</label>
                                            <div class="col-sm-6">
                                                <textarea class="form-control" readonly="readonly"
                                                          rows="5">{{ data.purpose }}</textarea>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-sm-12" for="TextArea">内网外</label>
                                            <div class="col-sm-6">
                                                <input class="form-control" id="ip_type"
                                                       value={{ data.ip_type }} readonly="readonly"></input>
                                            </div>
                                        </div>

                                        <!--
                            <div class="form-group">
                              <label class="col-sm-12" for="TextArea">机器配置和数量</label>
                              <div class="col-sm-6">
                                  <input class="form-control" id="config" value={{data.config}} readonly="readonly" ></input>
                              </div>
                              <input tpye="text" class="form-control col-sm-3" value={{data.number}} id='number' style="width: 5%" readonly="readonly"></input>
                            </div>-->

                                        {% for config in data.config %}
                                            <div class="form-group machine-config-all">
                                                <label class="col-sm-12">机器配置</label>
                                                <div class="col-lg-3">
                                                    <div class="input-group">
                                                        <input type="text" class="form-control machine-config-cpu"
                                                               readonly="readonly" value={{ config.config_cpu_value }}>
                                                        <span class="input-group-addon">CPU核心数</span>
                                                    </div>
                                                </div>
                                                <div class="col-lg-3">
                                                    <div class="input-group">
                                                        <input type="text" class="form-control machine-config-mem"
                                                               readonly="readonly" value={{ config.config_mem_value }}>
                                                        <span class="input-group-addon">内存G</span>
                                                    </div>
                                                </div>
                                                <div class="col-lg-3">
                                                    <div class="input-group">
                                                        <input type="text" class="form-control machine-config-mem"
                                                               readonly="readonly" value={{ config.config_disk_value }}>
                                                        <span class="input-group-addon">硬盘G</span>
                                                    </div>
                                                </div>
                                                <input tpye="text" class="form-control" style="width: 5%"
                                                       readonly="readonly" value={{ config.config_number }}台></input>
                                            </div>
                                        {% endfor %}

                                        <div class="form-group">
                                            <label class="col-sm-12" for="TextArea">其他需求(可选)</label>
                                            <div class="col-sm-6">
                                                <textarea class="form-control" id="requirements" rows="5"
                                                          readonly="readonly">{{ data.requirements }}</textarea>
                                            </div>
                                        </div>

                                        <div class="form-group">
                                            <label class="col-sm-12">审核流程步骤</label>
                                            <div class="col-sm-6">
                                                <div class="ystep1"></div>
                                            </div>
                                        </div>


                                        <div class="form-group" id='append_before'>
                                            <div class="col-sm-6">
                                                {% if data.recommit %}
                                                    <button type="button" class="btn btn-primary" id='bt-commit'>提交
                                                    </button>
                                                {% endif %}
                                                {% if data.can_execute %}
                                                    <button type="button" class="btn btn-success" id='bt-load'>已购买
                                                    </button>
                                                {% endif %}
                                            </div>
                                        </div>

                                        {% if data.opinion %}
                                            <div class="form-group">
                                                <label class="col-sm-12" for="TextArea">审批意见</label>
                                                <div class="col-sm-6">
                                                    <textarea class="form-control" rows="3" id="opinion"
                                                              readonly="readonly">{{ data.opinion }}</textarea>
                                                </div>
                                            </div>
                                        {% else %}
                                            <div class="form-group">
                                                <label class="col-sm-12" for="TextArea">审批意见</label>
                                                <div class="col-sm-6">
                                                    <textarea class="form-control" rows="3" id="opinion"
                                                              readonly="readonly">无</textarea>
                                                </div>
                                            </div>
                                        {% endif %}

                                    </form>
                                    <hr>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h4 class="modal-title" id="myModalLabel">执行中...请勿关闭或者刷新页面</h4>
                        </div>
                        <div class="modal-body">
                            <form class="form-horizontal" role="form">
                                {% if data.can_execute %}
                                    {% if not data.has_approved %}
                                        <div class="form-group" id='load' style="display: none;">
                                            <label class="col-sm-12"></label>
                                            <div class="col-sm-12">
                                                <div class="ball"></div>
                                            </div>
                                        </div>
                                    {% endif %}
                                {% endif %}
                                <div class="form-group" id='show-msg'>
                                    <label class="col-sm-3 control-label"></label>
                                    <div class="col-sm-8">
                                        <p id='load-msg'></p>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div class="modal-footer" id="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        </div>
                    </div><!-- /.modal-content -->
                </div><!-- /.modal-dialog -->
            </div>

        </div>
    </div>
{% endblock %}
{% block bodyjs %}
    <script src="/static/js/machine_myworkflow.js?v=5011b14bd545f40c9ba43efb8d08822a888b3b68"></script>
    <script src="/static/js/ystep.js"></script>
{% endblock %}
{% block css %}
    <link href="/static/css/ystep.css" rel="stylesheet" type="text/css">
    <link href="/static/css/load.css" rel="stylesheet" type="text/css">
{% endblock %}
